// includes variable
var jsLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
// includes
// ->convenience
jsLoader.loadSubScript("chrome://istorclient/content/convenience.js");
// ->JSON
Include(MyContent + "json2.js");
// ->Classes
Include(MyContent + "Classes.js");
// ->ContentNodes
Include(MyContent + "ContentNodes.js");
// ->TreeManager
Include(MyContent + "TreeManager.js");
// ->UpdateManager
Include(MyContent + "UpdateManager.js");
// ->TorrentOperations
Include(MyContent + "TorrentOperations.js");

// create the torrent list
// as it stands, an item can be any type
var TorrentList = new Array();
var TreeManager = new TreeManagerClass();
var SelectedTorrent;
var TreeId = "istorclient-torrenttree";
var IsFrameLoaded = false;
var Control = $('istorclient-iscontrol');
function CreateTree() {
	// addcolumn:treeid,id,label,flex,splitter,type
	TreeManager.CreateTree(document.getElementById("istorclient-list-box"), TreeId, 1, "torrentlist_click();", "SetSelectedTorrent();");
	TreeManager.AddColumn(TreeId, "torrentstatus", locale("istorclient.tor.status"), 3, true);
	TreeManager.AddColumn(TreeId, "torrentname", locale("istorclient.tor.name"), 25, true);
	TreeManager.AddColumn(TreeId, "torrenteta", locale("istorclient.tor.eta"), 2, true);
	TreeManager.AddColumn(TreeId, "torrentprogress", locale("istorclient.tor.progress"), 8, true, "progressmeter");
	TreeManager.AddColumn(TreeId, "torrentdown", locale("istorclient.tor.down"));
	TreeManager.AddColumn(TreeId, "torrentup", locale("istorclient.tor.up"));
	TreeManager.AddColumn(TreeId, "torrentsized", locale("istorclient.tor.saved"));
	TreeManager.AddColumn(TreeId, "torrentsize", locale("istorclient.tor.total"));
}
function InitIsTorClient() {
	CreateTree();
	StartUpdater();
};

function SetIsFrameLoaded(){
	IsFrameLoaded = true;
}
function torrentlist_click() {
	if (!SelectedTorrent) {return false;}
	window.open('http://'+SelectedTorrent.server+'.imageshack.us/tor/browse/?id='+SelectedTorrent.id);
	return true;
}
